﻿namespace Ngs.Extensions
{
    using System;
    using System.Linq.Expressions;
    using System.Text;

    public static class StringBuilderExtensions
    {
        private const string bracketFormat = "[{0}]";

        static StringBuilderExtensions()
        {
        }

        public static StringBuilder AppendIfNotNullOrEmpty(this StringBuilder builder, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                builder.Append(value);
            }
            return builder;
        }

        public static StringBuilder AddSpace(this StringBuilder builder)
        {
            builder.Append(StringConstants.Space);
            return builder;
        }


        public static StringBuilder With(this StringBuilder builder, char c)
        {
            builder.Append(c);
            return builder;
        }

        public static StringBuilder WithComma(this StringBuilder builder)
        {
            return With(builder, StringConstants.Comma);
        }

        public static StringBuilder WithColon(this StringBuilder builder)
        {
            return With(builder, StringConstants.Colon);
        }

        public static StringBuilder AppendWithColon(this StringBuilder builder, string value)
        {
            builder.Append(value);
            builder.Append(StringConstants.Colon);
            return builder;
        }

        public static string SurroundWithBracket(this string value)
        {
            return string.Format(bracketFormat, value);
        }
    }
}
